package com.tofacebook.proxy;

import com.tofacebook.model.Emp;
import com.tofacebook.service.EmpService;
import com.tofacebook.service.impl.EmpServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
public class EmpStaticProxy implements EmpService {

    //代理目标对象
    private EmpServiceImpl empServiceImpl;

    public EmpStaticProxy(EmpServiceImpl empServiceImpl) {
        this.empServiceImpl = empServiceImpl;
    }

    public Emp getEmpByEmpId(long empId) {
        log.info("操作之前，empId的值为：{}",empId);
        Emp emp = empServiceImpl.getEmpByEmpId(empId);
        log.info("操作之后，Emp对象的值为：{}",emp);
        return emp;
    }

    public int saveEmp(Emp emp) {
        log.info("操作之前，传递的值为：{}", emp);
        int num = empServiceImpl.saveEmp(emp);
        log.info("操作之后：{}", num);
        return num;
    }
}
